home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / biz / demo / StylusDemo.lha / Stylus_Demo / REXX / Status.pvrx < prev    next >
Text File  |  1995-02-15  |  11KB  |  393 lines

  1. /***************************************************************************
  2. *                                                                          *
  3. *  $VER: Status.pvrx 3.0 (11.Oct.93)                                       *
  4. *   Copyright © 1993 by Stylus, Inc.                                       *
  5. *   Author:  Jeff Blume                                                    *
  6. *                                                                          *
  7. *   This macro reports the status of the current project or selected       *
  8. *      object(s):                                                          *
  9. *                                                                          *
  10. *   Project Status:                                                        *
  11. *     1. Num layers                                                        *
  12. *     2. Num objs                                                          *
  13. *     3. Total Points                                                      *
  14. *     3b. Avg Number of Points - Not implemented                           *
  15. *     5. Largest object with test against RIP limits.                      *
  16. *     6. Magnification                                                     *
  17. *     7. File Size                                                         *
  18. *     8. Fonts USED - Not implemented                                      *
  19. *                                                                          *
  20. *   Object Status:                                                         *
  21. *     1. Attrs  (Color names not implemented)                              *
  22. *     2. Num. points                                                       *
  23. *     3. Layer occupied                                                    *
  24. *     4. Magnetism state                                                   *
  25. *                                                                          *
  26. *                                                                          *
  27. ***************************************************************************/
  28.  
  29. /*
  30. address 'ProVector'
  31. call open STDOUT,"RAM:RxOut.txt",W
  32. call open STDERR,"RAM:RxErr.txt",W
  33. trace R
  34. */
  35.  
  36. if ~show('Libraries','rexxsupport.library') then
  37.         call addlib('rexxsupport.library',0,-30,0)
  38.  
  39. options results
  40.  
  41. /* Try to get exclusive lock on project window.
  42.     If can't get lock, not polite to interrupt. */
  43. 'Lock Wait'
  44.  
  45. /* Initialize some variables */
  46. TotalPolys = 0
  47. TotalPts = 0
  48. MaxObj = 0
  49. TotalMisc = 0
  50.  
  51. /* Check for selected objs */
  52. 'SelectList' Sel; SelN = Result
  53. if SelN ~= 0 then call StatusObj
  54. else call StatusProj
  55.  
  56. 'UnLock'
  57.  
  58.  
  59. EXIT
  60.  
  61.  
  62. STATUSPROJ:
  63.     'Prompt "Gathering Project Stats."'
  64.     /* Get list of Layer names */
  65.     'CurrentLayer';        CurLay = Result
  66.     'GetLayers' LayList;    NumLay = Result
  67.     /* Loop through list of layers */
  68.     do k=0 for NumLay
  69.         /* Select all objs in layer */
  70.         'FirstObj' LayList.k
  71.         if Result = 0 then iterate k; else Objs.0 = Result
  72.         'TypeOf' Objs.0;    ObjType = Result
  73.         select
  74.             when ObjType = "Polygon" | ObjType = "Polyline" then
  75.                 do
  76.                     TotalPolys = TotalPolys + 1
  77.                     'GetPoints' Objs.0 ObjPts; NumPts=Result
  78.                     if MaxObj < NumPts then do
  79.                         MaxObj = NumPts
  80.                         MaxObjPtr = Objs.0
  81.                         end /* End If */
  82.                     else NOP
  83.                     TotalPts = TotalPts + NumPts
  84.                 end
  85.             when ObjType ="Group" then
  86.                     do
  87.                         TotalMisc = TotalMisc + 1
  88.                         call CountGroup Objs.0
  89.                     end
  90.             otherwise TotalMisc = TotalMisc + 1
  91.         end
  92.         do i = 1
  93.             j = i - 1
  94.             'NextObj' Objs.j; Objs.i = result
  95.             if Objs.i = 0 then leave i
  96.             'TypeOf' Objs.i;    ObjType = Result
  97.             select
  98.                 when ObjType = "Polygon" | ObjType = "Polyline" then
  99.                     do
  100.                         TotalPolys = TotalPolys + 1
  101.                         'GetPoints' Objs.i ObjPts; NumPts=Result
  102.                         if MaxObj < NumPts then
  103.                             do
  104.                                 MaxObj = NumPts
  105.                                 MaxObjPtr = Objs.i
  106.                             end /* End If */
  107.                         else NOP
  108.                         TotalPts = TotalPts + NumPts
  109.                     end
  110.                 when ObjType ="Group" then
  111.                     do
  112.                         TotalMisc = TotalMisc + 1
  113.                         call CountGroup Objs.i
  114.                     end
  115.                 otherwise TotalMisc = TotalMisc + 1
  116.             end    /* end select */
  117.         end    /* Obj list loop */
  118.     end  /* NumLay loop */
  119.     call Magnification
  120.     call FileSize
  121.     call DefGads
  122.     'EndPrompt'
  123.     address REXXREQUEST 'GetRequest Gads';    OK = Result
  124.     call MaxObject
  125. return
  126.  
  127.  
  128. STATUSOBJ:
  129.     /* Getattrs, count points */
  130.     MaxObj = 0
  131.     do i = 0 to SelN-1
  132.         'Prompt "Gathering Object Stats."'
  133.         'GetAttrs' Sel.i Attrs
  134.         'LayerOf' Sel.i;    LName = Result
  135.         'GetMagnets MagList'; NMags = Result
  136.         if NMags = 0 then Magnet = "OFF"
  137.         else
  138.             do m=0 for NMags
  139.                 if Sel.i = MagList.m then
  140.                     do
  141.                         Magnet = "ON"
  142.                         leave m
  143.                     end
  144.                 Magnet = "OFF"
  145.             end
  146.         'TypeOf' Sel.i;    ObjType = Result
  147.         select
  148.             when ObjType = "Polygon" | ObjType = "Polyline" then
  149.                 do
  150.                     'GetPoints' Sel.i ObjPts; TotalPts=Result
  151.                     Attrs.Font = "None";    Attrs.PointSize = "None"
  152.                 end
  153.             /* Even better - restructure whole mess */
  154.             when ObjType = "Group" then
  155.                 do
  156.                     TotalMisc = TotalMisc + 1
  157.                     call CountGroup Sel.i
  158.                 end
  159.             otherwise TotalPts = "Object Not Poly"
  160.         end    /* end select */
  161.         call DefGads
  162.         'EndPrompt'
  163.         address REXXREQUEST 'GetRequest Gads';    OK = Result
  164.         MaxObj = TotalPts
  165.         MaxObjPtr = Sel.i
  166.         call MaxObject
  167.     end    /* end i (Selected) loop */
  168. return
  169.  
  170.  
  171. COUNTGROUP:
  172.     procedure expose TotalPolys TotalPts TotalMisc MaxObj MaxObjPtr
  173.     arg Grp
  174.     'GroupObj' Grp;    GrpObj.0 = Result
  175.         'TypeOf' GrpObj.0;    GrpType = Result
  176.         select
  177.             when GrpType = "Polygon" | ObjType = "Polyline" then
  178.                 do
  179.                     TotalPolys = TotalPolys + 1
  180.                     'GetPoints' GrpObj.0 ObjPts; NumPts=Result
  181.                     if MaxObj < NumPts then
  182.                         do
  183.                             MaxObj = NumPts
  184.                             MaxObjPtr = GrpObj.0
  185.                         end /* End If */
  186.                     else NOP
  187.                     TotalPts = TotalPts + NumPts
  188.                 end
  189.             /* Recursion can't handle Nested Groups, need to save state of
  190.                   loop first- shouldn't REXX do that for me - yes, when PROCEDURE ?  */
  191.             when GrpType ="Group" then
  192.                 do
  193.                     TotalMisc = TotalMisc + 1
  194.                     call CountGroup GrpObj.0
  195.                 end
  196.             otherwise TotalMisc = TotalMisc + 1
  197.         end    /* end select */
  198.     do g = 1
  199.         h = g - 1
  200.         'NextObj' GrpObj.h;    GrpObj.g = Result
  201.         if GrpObj.g = 0 then leave g
  202.         'TypeOf' GrpObj.g;    GrpType = Result
  203.         select
  204.             when GrpType = "Polygon" | ObjType = "Polyline" then
  205.                 do
  206.                     TotalPolys = TotalPolys + 1
  207.                     'GetPoints' GrpObj.g ObjPts; NumPts=Result
  208.                     if MaxObj < NumPts then
  209.                         do
  210.                             MaxObj = NumPts
  211.                             MaxObjPtr = GrpObj.g
  212.                         end /* End If */
  213.                     else NOP
  214.                     TotalPts = TotalPts + NumPts
  215.                 end
  216.             when GrpType ="Group" then
  217.                 do
  218.                     TotalMisc = TotalMisc + 1
  219.                     call CountGroup GrpObj.g
  220.                 end
  221.             otherwise TotalMisc = TotalMisc + 1
  222.         end    /* end select */
  223.     end
  224. return
  225.  
  226.  
  227. MAXOBJECT:
  228.     /* If MaxObj >= 1500 pts, it exceeds limit of many PostScript devices! */
  229.     /* Warn & offer to select obj */
  230.     if MaxObj = "Object Not Poly" then return
  231.     if MaxObj >= 1500 then
  232.         do
  233.             'GetBool "Obj exceeds older PostScript devices!" "Ok" "Select"'
  234.             if RC = 25 then 'SelectObj MaxObjPtr'
  235.         end
  236. return
  237.  
  238.  
  239. FILESIZE:
  240.     'GetCurrProj';    ProjPtr = Result
  241.     'ProjName ProjPtr';    FName = Result
  242.     FSize = word( statef(FName), 2)
  243. return
  244.  
  245.  
  246. MAGNIFICATION:
  247.     Mag = 1
  248.     /* Get the page width & height */
  249.     'GetPageDims' Dims        /* Dims.Width;Dims.Height */
  250.     /* Get the current view */
  251.     'GetView' View            /*View.X1;View.Y1;View.X2;View.Y2*/
  252.     /* View Width & Height */
  253.     W = View.X2-View.X1; H = View.Y2-View.Y1
  254.     if W >= H then Mag = Dims.Width/W
  255.     else Mag = Dims.Height/H
  256. return
  257.  
  258.  
  259. DEFGADS:
  260. /* Define Public Screen */
  261. Gads.PubScreen = "PROVECTOR"
  262.  
  263. if SelN ~=0 then call ObjReq
  264. else call ProjReq
  265. return
  266.  
  267.  
  268. PROJREQ:
  269. /* Define Window */
  270. Gads.0.LeftEdge = 118; Gads.0.TopEdge = 59
  271. Gads.0.Width = 352; Gads.0.Height = 94
  272. Gads.0.Label = "Project Status"
  273.  
  274. /* Define Label Gadgets */
  275. Gads.1.LeftEdge = 14; Gads.1.TopEdge = 8
  276. Gads.1.Width = 112; Gads.1.Height = 12
  277. Gads.1.Type = Label
  278. Gads.1.Label = "Current Layer = "||CurLay
  279.  
  280. Gads.2.LeftEdge = 14; Gads.2.TopEdge = 16
  281. Gads.2.Width = 112; Gads.2.Height = 12
  282. Gads.2.Type = Label
  283. Gads.2.Label = "Total Layers = "||NumLay
  284.  
  285. Gads.3.LeftEdge = 14; Gads.3.TopEdge = 24
  286. Gads.3.Width = 112; Gads.3.Height = 12
  287. Gads.3.Type = Label
  288. Gads.3.Label = "Total Polygons = "||TotalPolys||" polygons,"
  289.  
  290. Gads.4.LeftEdge = 14; Gads.4.TopEdge = 32
  291. Gads.4.Width = 112; Gads.4.Height = 12
  292. Gads.4.Type = Label
  293. Gads.4.Label = "Total Points = "||TotalPts||" points."
  294.  
  295. Gads.5.LeftEdge = 14; Gads.5.TopEdge = 40
  296. Gads.5.Width = 112; Gads.5.Height = 12
  297. Gads.5.Type = Label
  298. Gads.5.Label = "Other Objs (Text, Groups, etc.) = "||TotalMisc
  299.  
  300. Gads.6.LeftEdge = 14; Gads.6.TopEdge = 48
  301. Gads.6.Width = 112; Gads.6.Height = 12
  302. Gads.6.Type = Label
  303. Gads.6.Label = "Largest Object = "||MaxObj||" points."
  304.  
  305. Gads.7.LeftEdge = 14; Gads.7.TopEdge = 56
  306. Gads.7.Width = 112; Gads.7.Height = 12
  307. Gads.7.Type = Label
  308. Gads.7.Label = "File Size = "||FSize||" bytes."
  309.  
  310. Gads.8.LeftEdge = 15; Gads.8.TopEdge = 64
  311. Gads.8.Width = 112; Gads.8.Height = 12
  312. Gads.8.Type = Label
  313. Gads.8.Label = "Magnification = "||Mag||"x"
  314.  
  315. /* Total Gadgets + Window */
  316. Gads.NumGads = 9
  317. return    /* return DefGads */
  318.  
  319.  
  320. OBJREQ:
  321. /* Define Window */
  322. Gads.0.LeftEdge = 118; Gads.0.TopEdge = 59
  323. Gads.0.Width = 272; Gads.0.Height = 114
  324. Gads.0.Label = "Object Status"
  325.  
  326. /* Define Label Gadgets */
  327. Gads.1.LeftEdge = 14; Gads.1.TopEdge = 8
  328. Gads.1.Width = 112; Gads.1.Height = 12
  329. Gads.1.Type = Label
  330. Gads.1.Label = "Total Points = "||TotalPts
  331.  
  332. Gads.2.LeftEdge = 14; Gads.2.TopEdge = 16
  333. Gads.2.Width = 112; Gads.2.Height = 12
  334. Gads.2.Type = Label
  335. Gads.2.Label = "Fill Type = "||Attrs.FillType
  336.  
  337. Gads.3.LeftEdge = 14; Gads.3.TopEdge = 24
  338. Gads.3.Width = 112; Gads.3.Height = 12
  339. Gads.3.Type = Label
  340. Gads.3.Label = "Fill Value = "||Attrs.FillVal
  341.  
  342. Gads.4.LeftEdge = 14; Gads.4.TopEdge = 32
  343. Gads.4.Width = 112; Gads.4.Height = 12
  344. Gads.4.Type = Label
  345. Gads.4.Label = "Line Type = "||Attrs.EdgeType
  346.  
  347. Gads.5.LeftEdge = 14; Gads.5.TopEdge = 40
  348. Gads.5.Width = 112; Gads.5.Height = 12
  349. Gads.5.Type = Label
  350. Gads.5.Label = "Line Value = "||Attrs.EdgeVal
  351.  
  352. Gads.6.LeftEdge = 14; Gads.6.TopEdge = 48
  353. Gads.6.Width = 112; Gads.6.Height = 12
  354. Gads.6.Type = Label
  355. Gads.6.Label = "Line Weight = "||Attrs.EdgeWidth
  356.  
  357. Gads.7.LeftEdge = 14; Gads.7.TopEdge = 56
  358. Gads.7.Width = 112; Gads.7.Height = 12
  359. Gads.7.Type = Label
  360. Gads.7.Label = "Line Join = "||Attrs.LineJoin
  361.  
  362. Gads.8.LeftEdge = 14; Gads.8.TopEdge = 64
  363. Gads.8.Width = 112; Gads.8.Height = 12
  364. Gads.8.Type = Label
  365. Gads.8.Label = "Font = "||Attrs.Font
  366.  
  367. Gads.9.LeftEdge = 14; Gads.9.TopEdge = 72
  368. Gads.9.Width = 112; Gads.9.Height = 12
  369. Gads.9.Type = Label
  370. Gads.9.Label = "Point Size = "||Attrs.PointSize
  371.  
  372. Gads.10.LeftEdge = 15; Gads.10.TopEdge = 80
  373. Gads.10.Width = 112; Gads.10.Height = 12
  374. Gads.10.Type = Label
  375. Gads.10.Label = "Magnetism = "||Magnet
  376.  
  377. Gads.11.LeftEdge = 14; Gads.11.TopEdge = 88
  378. Gads.11.Width = 112; Gads.11.Height = 12
  379. Gads.11.Type = Label
  380. Gads.11.Label = "Layer = "||LName
  381.  
  382. /* Total Gadgets + Window */
  383. Gads.NumGads = 12
  384. return    /* return ObjReq */
  385.  
  386.  
  387. /*
  388.     address command "'list >PIPE:FSize HD3:PV/DR2D_Drawings/"||FName||" LFormat=%L'"
  389.     /* Above should have worked, but instead passed "'list" as the command */
  390.     /* Below worked */
  391.     address command list ">PIPE:FSize HD3:PV/DR2D_Drawings/"||FName||" LFormat=%L"
  392. */
  393.